﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TrainningWeekend
{
    class Creature
    {
        public virtual void Live()
        {
            Console.WriteLine("生物在生长");
        }

        private DateTime dateOfBirth;

        public DateTime DateOfBirth
        {
            get
            {
                return dateOfBirth;
            }
            set
            {
                if (DateTime.Now < value)
                {
                    dateOfBirth = DateTime.Now;
                }
                else
                {
                    dateOfBirth = value;
                }

            }
        }

        public int Age
        {
            get
            {
                int currYear = DateTime.Now.Year;
                int birthYear = dateOfBirth.Year;
                return currYear - birthYear;
            }
        }
    }

    class Animal : Creature
    {
        public override void Live()
        {
            Console.WriteLine("动物在生长");
        }

        public void Walk()
        {
            Console.WriteLine("walking");
        }
    }
}
